<div class="tableform widgetconfig">
  <h4>板块基础设置</h4> 
  <div class="division">
    <table width="100%" cellpadding="0" cellspacing="0">
        <tr>
          <th>版块标题</th>
          <td><input class="inputstyle" type="text" name="title" value="<{$setting.title}>" style="width:150px" />&nbsp;&nbsp;<i>留空则不显示标题项</i></td>
          <th>版块标题图片</th>
          <td><input type=hidden name="ad_pic" value="<{$setting.ad_pic}>"><input name='ad_pic' class="imgsrc inputstyle" id="ad_pic" value="<{$setting.ad_pic}>"><input type=button value="<{t app='b2c'}>上传图片<{/t}>" class="uploadbtn" onclick="addPic()">&nbsp;&nbsp;<i>不填则显示文字标题</i></td>
        </tr>
    </table>
  </div>
  <div class="clearfix">
    <{button label=$___b2c="添加广播"|t:'b2c' app="desktop" icon="btn_add.gif" id="add_ad_bt" onclick=""}>
 </div>
 
  <div class="division" style="margin-top:8px;" id="bt">
  <{foreach from=$setting.bt item=data key=key}>
    <div id="bt_<{$data.i}>" class="configad">
      <table width="100%" cellpadding="0" cellspacing="0">
        <input type=hidden name=bt[<{$data.i}>][type] value="<{$data.type}>">
        <input type=hidden name=bt[<{$data.i}>][i] value="<{$data.i}>">
        <tr>
          <th width="20%">链接地址:</th>
          <td><input class="inputstyle" type="text" style="width:60%" name=bt[<{$data.i}>][tolink] value="<{$data.tolink}>"><span onclick="delLink(this);"><{img src="bundle/delecate.gif" style="cursor:pointer;" alt="删除" title="删除" app="desktop"}></span></td>
        </tr>
        <tr>
          <th width="20%">广播:</th>
          <td><input class="inputstyle" type="text" style="width:60%" name=bt[<{$data.i}>][text] value="<{$data.text}>"></td>
        </tr>
      </table>
    </div>
    <{/foreach}>
    </div>
</div>

<script>
$('add_ad_bt').addEvent('click',function(){
  var d=new Date();
  var i=d.getTime();
  $('bt').adopt(new Element('div').set('html','\
    <div class="configad" style="margin-top:6px;">\
       <table cellpadding="0" cellspacing="0">\
          <tr><th>链接地址:</th><td><input class="inputstyle" type="text" style="width:60%" name=bt['+i+'][tolink] size=15><span onclick="delLink(this);"><{img src="bundle/delecate.gif" style="cursor:pointer;" alt="删除" title="删除" app="desktop"}></span></td></tr>\
          <tr><th>广告说明：</th><td><input class="inputstyle" type="text" style="width:60%" name=bt['+i+'][text]></td></tr>\
       </table>\
      <input type=hidden name=bt['+i+'][i] value="'+i+'">\
    </div>\
  ').getFirst());
    $('pic['+i+']').addEvent('click',function(e){bindevent(this)});
});

function addPic(){
    var url='index.php?app=desktop&act=alertpages&goto='+encodeURIComponent("index.php?app=image&ctl=admin_manage&act=image_broswer&type=big");
    Ex_Loader('modedialog',function(){
        return new imgDialog(url,{onCallback:function(image_id,image_src){
                $(ad_pic).value=image_src;
        }}) ;
    });
}   

delLink=function(o){$(o).getParent('.configad').remove();}
</script>
